import sys
import itertools
import copy
input = sys.stdin.readline
for _ in range(int(input())):
n = int(input())
b = list(map(int, input().split()))
s = sum(b)
if s % (n * (n + 1) // 2):
print("NO")
continue
s //= (n * (n + 1) // 2)
b = itertools.starmap(int.__sub__, zip(b[-1:] + b[:-1], b))
b = map(s.__add__, b)
b = map(n.__rfloordiv__, b)
if sum(copy.deepcopy(b)) != s or max(copy.deepcopy(b)) > 1e9 or min(copy.deepcopy(b)) < 1:
print("NO")
continue
print("YES")
print(*b)
#include <bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
//find_by_order, order_of_key
#ifdef LOCAL
#define db(x) cout << "Line " << __LINE__ << ": " << #x << " = " << to_string(x) << endl;
#define endl endl
#else
#define db(x) 42;
#define endl '\n'
#endif
#define int long long
#define ll long long
#define all(x) x.begin(),x.end()
#define rev(x) x.rbegin(),x.rend()
#define nd << " " <<
#define ln << endl
#define lbr cout << endl;
#define fi first
#define se second
#define pb push_back
#define rep(i, s, e) for(int i = s; i < e; i++)
#define repr(i, s, e) for(int i = s; i >= e; i--)
#define reps(i,s,e,step) for(int i=s; i < e; i+=step)
#define repa(x, a) for(auto &x: a)
#define vc vector
#define vi vector<int>
#define pii pair<int, int>
#define endt return 0;
#define sz(a) ((long long)a.size())
#define odd %2==1
#define even %2==0
#define llmx LONG_LONG_MAX
#define llmn LONG_LONG_MIN
#define yn(f) cout << ((f)?"YES":"NO") << endl;
#define inrange(x,a,b) ((x>=min(a,b)) && (x<=max(a,b)))
//use (long long)round(pow(x, y))
signed solve(int& tc){
//db(tc)
int n;
cin >> n ;
vi b(n);
rep(i, 0, n){
cin >> b[i];
}
ll S=2*(accumulate(all(b), 0LL));
ll x=S/(n*(n+1));
if(x*(n*(n+1))!=S){
yn(0)
endt
}
vi a(n);
rep(i,0,n){
a[i]=(x+b[(i-1+n)%(n)]-b[i]);
if(a[i]%n!=0 || inrange(a[i]/n, 1LL, (ll)(1e9))==0){
yn(0)
endt
}
a[i]/=n;
}
yn(1)
rep(i,0,n) cout << a[i] << " ";
cout << endl;
return 0;
}
signed main(){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin.exceptions(ios::badbit | ios::failbit);
#ifdef LOCAL
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
#endif
int tc=1;
cin >> tc;
for(int i=1; i<=tc; i++) solve(i);
return 0;
}
1720A - Burenka Plays with Fractions | 3A - Shortest path of the king |
1720C - Corners | 574A - Bear and Elections |
352B - Jeff and Periods | 1244A - Pens and Pencils |
1670A - Prof Slim | 1189A - Keanu Reeves |
678A - Johny Likes Numbers | 1699C - The Third Problem |
1697D - Guess The String | 754B - Ilya and tic-tac-toe game |
760A - Petr and a calendar | 1573A - Countdown |
166A - Rank List | 1631B - Fun with Even Subarrays |
727A - Transformation from A to B | 822B - Crossword solving |
1623A - Robot Cleaner | 884B - Japanese Crosswords Strike Back |
862B - Mahmoud and Ehab and the bipartiteness | 429A - Xor-tree |
1675C - Detective Task | 950A - Left-handers Right-handers and Ambidexters |
672B - Different is Good | 1C - Ancient Berland Circus |
721A - One-dimensional Japanese Crossword | 1715B - Beautiful Array |
60B - Serial Time | 453A - Little Pony and Expected Maximum |